I have this table where the top cell spans about 7 columns. I am using DOORS 7.1. My Table c1 | c2 | c3 | c4 | c5 | c6 | c7 | c1 | c2 | c3 | c4 | c5 | c6 | c7 | I am trying to count the number of columns in the entire table (my desired result is 7 in this case), but I am getting mixed results. I use something like this: Object oCount Object obj = current for oCount in row(obj) do { if(!isMulticolumn) { curNumColumns = curNumColumns + multicolumn } else { curNumColumns++ } } Some Xs are printed based on the value in curNumColumns. Now, when the script finishes, in some tables I will get the right amount of Xs, like |X|X|X|X|X|X|X|. Other times I get a large number of them, about double I think. The top cell has an attribute called multicolumn, I assign it the value 7 to tell my script that it should add 7 to the total amount of columns, and I think this is compounding the problem. When looping through to count columns, am I counting the first cell i.e. the spanning one, or is it the next row? In the documentation I see something about a "header object" that is hidden, could this also be a part of the problem? mirlo - Sun Mar 21 11:03:48 EDT 2010 |
Re: Getting the number of columns in a table oCount."multicolumn" It is assigned, so for this example, just to keep things consistent, we will imagine there is a multicolumn of type int: int multicolumn =oCount."multicolumn" I wasn't sure if I could modify my original post or not, so I just replied. |
Re: Getting the number of columns in a table
Hey Mirlo,
|- Header
|-- row 1
| |- cell (1,1)
| |- cell (1,2)
|-- row 2
| |- cell (2,1)
| |- ...
|-- ...
|
Re: Getting the number of columns in a table Slapped this together on my way out the DOORS ..err.. door.
int CountColumns(Object oCurr)
{ // Count columns in the Table, of which the Object is a Cell
if (!cell(oCurr)) return(-1)
oRow = parent(oCurr)
if (null oRow) return(-1)
oTable = parent(oCell)
if (null oTable) return(-1)
CountMax = 0
CountRow = 0
for oRow in oTable do
{ CountRow = 0
for oCell in oRow do
{ CountRow++
}
if (CountRow > CountMax) CountMax = CountRow
}
return(CountMax)
} // end CountColumns()
|
Re: Getting the number of columns in a table llandale - Mon Mar 22 18:40:28 EDT 2010 Slapped this together on my way out the DOORS ..err.. door.
int CountColumns(Object oCurr)
{ // Count columns in the Table, of which the Object is a Cell
if (!cell(oCurr)) return(-1)
oRow = parent(oCurr)
if (null oRow) return(-1)
oTable = parent(oCell)
if (null oTable) return(-1)
CountMax = 0
CountRow = 0
for oRow in oTable do
{ CountRow = 0
for oCell in oRow do
{ CountRow++
}
if (CountRow > CountMax) CountMax = CountRow
}
return(CountMax)
} // end CountColumns()
Attachments attachment_14449807_tables.JPG |
Re: Getting the number of columns in a table mirlo - Thu Mar 25 11:41:17 EDT 2010
//************************
int CountColumns(Object oCurr, bool ConsiderDeletes)
{ // Count columns in the Table, of which the Object is a Cell
// When ConsiderDeletes, count deleted rows and Cells,
// otherwise ignore deleted rows and cells
if (null oCurr) return(-1)
Object oRow, oTable, oCell
int CountMax, CountRow
if (table(oCurr)) oTable = oCurr
elseif(row(oCurr)) oTable = parent(oCurr)
elseif(cell(oCurr))
{ oRow = parent(oCurr)
if (null oRow) return(-1)
oTable = parent(oRow)
}
else return(-1) // oCurr is not part of a table
if (null oTable) return(-1) // Cannot determine Table object
CountMax = 0
CountRow = 0
for oRow in table(oTable) do
{ if(!ConsiderDeletes and isDeleted(oRow)) continue
CountRow = 0
for oCell in row(oRow) do
{ if (!ConsiderDeletes and isDeleted(oCell)) continue
CountRow++
}
if (CountRow > CountMax) CountMax = CountRow
}
return(CountMax)
} // end CountColumns()
print "Count = " CountColumns(current Object, true) "\n"
print "Count = " CountColumns(current Object, false) "\n"
|
Re: Getting the number of columns in a table llandale - Thu Mar 25 12:43:17 EDT 2010
//************************
int CountColumns(Object oCurr, bool ConsiderDeletes)
{ // Count columns in the Table, of which the Object is a Cell
// When ConsiderDeletes, count deleted rows and Cells,
// otherwise ignore deleted rows and cells
if (null oCurr) return(-1)
Object oRow, oTable, oCell
int CountMax, CountRow
if (table(oCurr)) oTable = oCurr
elseif(row(oCurr)) oTable = parent(oCurr)
elseif(cell(oCurr))
{ oRow = parent(oCurr)
if (null oRow) return(-1)
oTable = parent(oRow)
}
else return(-1) // oCurr is not part of a table
if (null oTable) return(-1) // Cannot determine Table object
CountMax = 0
CountRow = 0
for oRow in table(oTable) do
{ if(!ConsiderDeletes and isDeleted(oRow)) continue
CountRow = 0
for oCell in row(oRow) do
{ if (!ConsiderDeletes and isDeleted(oCell)) continue
CountRow++
}
if (CountRow > CountMax) CountMax = CountRow
}
return(CountMax)
} // end CountColumns()
print "Count = " CountColumns(current Object, true) "\n"
print "Count = " CountColumns(current Object, false) "\n"
|
Re: Getting the number of columns in a table mirlo - Thu Apr 29 10:44:28 EDT 2010 The "for oChild in oParent" loop ignores the display set. I don't see why you cannot use that loop in place of the other two above. If you want to ignore invisible objects, then yes try "if (!isVisible(obj)) continue".
|
Re: Getting the number of columns in a table Hi Everyone, Please help me in the problem about the total number columns and rows in csv file. Is there anyway to find the total number of rows and columns of the csv file through the dxl script ? Actually one might ask that why I need it because I have the application which import the data from csv file to doors module and now the total number of rows and columns option is manual in it( I enter the number of rows and columns manually in the code), so I want to automate this option. A help will be highly appreciated. Thanks |
Re: Getting the number of columns in a table Salo33 - Tue Jul 05 07:30:17 EDT 2016 Hi Everyone, Please help me in the problem about the total number columns and rows in csv file. Is there anyway to find the total number of rows and columns of the csv file through the dxl script ? Actually one might ask that why I need it because I have the application which import the data from csv file to doors module and now the total number of rows and columns option is manual in it( I enter the number of rows and columns manually in the code), so I want to automate this option. A help will be highly appreciated. Thanks Create a stream and read in the first line of csv file. Count the number of commas, This is based on assumptions you haven't deliminated any commas in heading line. |
Re: Getting the number of columns in a table DOORSHAM - Tue Jul 05 09:36:19 EDT 2016 Create a stream and read in the first line of csv file. Count the number of commas, This is based on assumptions you haven't deliminated any commas in heading line. Dear Sir, I am new to door and not having experience, so could you please write the dxl code for finding the number of rows and columns in the dxl. Thanks |
Re: Getting the number of columns in a table Salo33 - Tue Jul 05 10:49:11 EDT 2016 Dear Sir, I am new to door and not having experience, so could you please write the dxl code for finding the number of rows and columns in the dxl. Thanks LOL |